<?php
if($action == 'update')
{
	echo $this->get_tag('form',array('action'=>$this->baseurl("/appforum/manageticket/$action/" . $data_list['id']),'method'=>'post'));
	echo $this->callElement("default/tools/tool_bar",array("buttons"=>array( array('type'=>'back'),array('type'=>'save')) ,"title" => "Ticket Information"));
	App::Module('DataGrid') ->setDisplay('FormListing')
							->addRow('Comments',App::load("Helper/Html")->textareaTag("data[Ticket][description]",$data_list['description'],array("class"=>"app_input check_notempty","rows"=>"15")) );

	if($data_list['file'] != "")
	{
		App::Module('DataGrid') ->addRow('File',App::Helper('Html')->LinkTag($this->baseurl("/uploads/filemanager/ticket/{$data_list['file']}"),"Download Attachment"));
	}


	App::Module('DataGrid') ->addRow('Status',App::load("Helper/Html")->selectTag("data[Ticket][status]",array("Active"=>"Active","Resolved"=>"Resolved","OnGoing"=>"OnGoing"),$data_list['status']))
							->Render();
	echo $this->callElement("default/tools/tool_bar",array("buttons"=>array( array('type'=>'back'),array('type'=>'save')) ,"position" => 'bottom'));
	echo $this->get_tag('/form');
}
else
{
	echo $this->callElement("default/tools/tool_bar",array("buttons"=>array( array('type'=>'back')) ,"title" => "Ticket Information"));
	if(!empty($data_list['data']))
    {
        $Grid = App::Module('DataGrid');
        $Grid->setHeader(array('#','Name', 'Comments', 'Date','Status','Options'));
        $Grid->setFooter($data_list['link'] . " " . $data_list['paging'] . " &nbsp;&nbsp; Total Entry : " . $data_list["total"]);
        foreach($data_list['data'] as $key=>$val)
        {	$attachment = ($val['file'] != "") ? " * " : "";
            $Grid->addRow(( ($data_list["page"] - 1) * $this->get_config('default_pagination') + $key + 1) . " {$attachment} ",
                            App::Model("Member")->fieldToField("id",$val['userid'],Array("f_name","l_name")),
                            substr(strip_tags($val['description']),0,50),
							App::Helper('Date')->dateFormated($val['dated'],'long'),
							$val['status'],
                            App::load("Helper/Html")->linkTag($this->baseurl('/appforum/manageticket/update/' . $val['id']),App::load("Helper/Html")->imgTag($this->baseurl('/images/admin/edit.gif'),NULL,array('title'=>'Edit ','alt' => 'Edit',"class"=>"icon")),array("title"=>"Edit user information"))
                            . App::load("Helper/Html")->linkTag("javascript:void(0)",App::load("Helper/Html")->imgTag($this->baseurl('/images/admin/remove.gif'),NULL,array('title'=>'Delete','alt'=>'Delete')),array('id'=>'Ticket_' . $val['id'],'class'=>'link_delete icon', 'title'=>'Ticket_' . $val['id']))
                            );
        }
        $Grid->Render();
    }
    else
    {
        echo $this->callElement('default/tools/message', array('caption' =>'Message','type' => 'error', 'message' => 'No Data found for Account'));
    }
	echo $this->callElement("default/tools/tool_bar",array("buttons"=>array( array('type'=>'back')) ,"position" => 'bottom'));
}

?>